VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "DAOLog"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit
Private mvarConnection As utilConexion 'local copy

Public Property Set Connection(ByVal vData As utilConexion)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.Connection = vData
    Set mvarConnection = vData
End Property

Public Function guardarNuevo(bean As bLog) As Boolean
On Error GoTo hnderr

Dim sql As String
sql = "INSERT INTO log(ncodigo, susuario, smensaje, smodulo,sopcion) "
sql = sql + "VALUES (nextval('seq_log'),'"
sql = sql + bean.bUsuario.sNombre + "','"
sql = sql + bean.sMensaje + "','" + bLog.sModulo + "','" + bLog.sOpcion + "')"

mvarConnection.Connection.Execute sql

hnderr:
If Err.Number = 0 Then Exit Function
guardarNuevo = UtilConstantes.OPT_ERROR_ENCONTRADO
Err.Clear
End Function


Public Function getLista() As Collection
On Error GoTo hnderr
Dim sql As String
Dim rst As New Recordset
Dim list As New Collection
Dim record As New bLog

sql = "SELECT ncodigo,susuario, fecha, smensaje "
sql = sql + "FROM log l INNER JOIN usuario u "
sql = sql + "ON u.snombre = l.susuario "
sql = sql + "ORDER BY fecha desc"
rst.Open sql, mvarConnection.Connection, adOpenForwardOnly

While Not rst.EOF
    Set record = New bLog
    If Not IsNull(rst.Fields("nCodigo")) Then record.nCodigo = rst.Fields("ncodigo").value
    If Not IsNull(rst.Fields("fecha")) Then record.dfecha = rst.Fields("fecha").value
    If Not IsNull(rst.Fields("smensaje")) Then record.sMensaje = rst.Fields("smensaje").value
    If Not IsNull(rst.Fields("susuario")) Then record.bUsuario.sNombre = rst.Fields("susuario").value
    rst.MoveNext
    list.Add record
Wend
Set getLista = list

hnderr:
If Err.Number = 0 Then Exit Function


End Function



